<!DOCTYPE html>
<html>
<head>
    {include file="_Fragment/meta" /}
    <link rel="stylesheet" href="/static/pear/component/pear/css/pear.css" />
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <blockquote class="layui-elem-quote">推荐引擎配置---上次更新时间  {$time}</blockquote>
        <form class="layui-form">
            <div class="main-container">
                <div class="layui-form-item">
                    <label class="layui-form-label">自动更新</label>
                    <div class="layui-input-inline"  style="width: 50%;">
                        <input type="number" name="days" value="{$inf.days}" min="1" autocomplete="off" placeholder="请填写自动更新天数" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">天</div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">推荐池课</label>
                    <div class="layui-input-inline"  style="width: 50%;">
                        <input type="number" name="course_num" value="{$inf.course_num}" min="1" autocomplete="off" placeholder="请填写推荐池课程数" class="layui-input">
                    </div>
                    <div class="layui-form-mid layui-word-aux">门</div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                                lay-filter="user-save">
                            <i class="layui-icon layui-icon-ok"></i>
                            保存
                        </button>
                        <button type="reset" class="pear-btn pear-btn-sm">
                            <i class="layui-icon layui-icon-refresh"></i>
                            重置
                        </button>
                    </div>
                </div>
                {:token_field()}
            </div>
        </form>
    </div>

</div>


{include file="_Fragment/javascript" /}
<script>
    layui.use(['form', 'jquery', 'element'], function() {
        let form = layui.form;
        let $ = layui.jquery;


        form.on('submit(user-save)', function(data) {
            layer.confirm('确定保存吗?', {
                icon: 3,
                title: '提示'
            }, function(index) {
                layer.close(index);
                let loading = layer.load();
                $.ajax({
                    url: '/Config/saveEngine',
                    data: JSON.stringify(data.field),
                    dataType: 'json',
                    contentType: 'application/json',
                    type: 'post',
                    success: function(result) {
                        layer.close(loading);
                        if (result.status == 0) {
                            layer.msg(result.msg, {
                                icon: 1,
                                time: 1000
                            });
                        } else {
                            layer.msg(result.msg, {
                                icon: 2,
                                time: 1000
                            });
                        }
                    }
                })
            });
            return false;
        });
    })
</script>
</body>
</html>
